home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 3⁄23⁄90 / 0085-C++ Help Plea-Mar90 < prev    next >
Encoding:
Text File  |  1990-03-23  |  24.2 KB  |  809 lines  |  [TEXT/GEOL]

  1. Item    1503284                         21-March-90        12:34PST
  2.  
  3. From:   V0754                           Troll Tech, Tom Storli,VAR
  4.  
  5. To:     CPLUS.DEV$                      C++ Interest List--Developers
  6.  
  7. Sub:    C++ Help Plea
  8.  
  9. HELP!
  10.  
  11. Can anyone tell me what is going on here?  Whenever I include the function
  12. "CCharGrid::IViewTemp()" listed below, CFront works fine, but the C compiler
  13. crashes.  It does'nt matter whether the function contains any lines of code or
  14. not.  If the function is commented out, the entire file compiles correctly.
  15. The function is listed at the end of this document, just before the listing of
  16. the C compiler output.
  17.  
  18. This is the output from the C Compiler after CFront has been run.
  19. If the above function (CCharGrid::IViewTemp()) is **not** commented out
  20. the C compiler makes it all the way to "# Total code size = 4222" and then
  21. crashes.
  22.  
  23. This code fragment is a personal use only copy of some of the routines in the
  24. THINK™ Object Class Library. I have modified these to run under MPW. This
  25. fragment is not for distribution, its sole purpose is to provide reference for
  26. the problem I need help with.
  27.  
  28.  
  29. #include <Windows.h>
  30. #include <Memory.h>
  31.  
  32. #defineNOTHING 0   /* Useful flag  */
  33. #defineMax(x, y)   ((x) > (y) ? (x) : (y))
  34. #define topLeft(r) (((Point *) &(r))[0])
  35.  
  36. typedeflong**LongHandle;
  37. typedefvoid (*VoidFunc)(...);  /* Ptr to a function returning void */
  38. typedefBoolean (*BooleanFunc)(...);/* Ptr to a Boolean function*/
  39.  
  40.  
  41.  
  42.  
  43. class CTask : HandleObject {   /* Class Declaration*/
  44.  
  45. protected:
  46.  
  47.    short   nameIndex;  /* Index for name in string list*/
  48.  
  49.    CTask(short aNameIndex) { nameIndex = aNameIndex; }
  50.  
  51. public:
  52.  
  53.    short   GetNameIndex(void) { return(nameIndex); }
  54.  
  55.    virtual voidDo(void) {}
  56.    virtual voidUndo(void) {}
  57.    virtual voidRedo(void) { Undo(); }
  58. };
  59.  
  60.  
  61.  
  62.  
  63. class CMouseTask : public CTask {  /* Class Declaration*/
  64.  
  65. public:
  66.    /** Contruction/Destruction **/
  67.    CMouseTask(short aNameIndex)
  68.    : CTask(aNameIndex) {}
  69.    /** Mouse Tracking **/
  70.    virtual voidBeginTracking(Point *startPt) {}
  71.    virtual voidKeepTracking(Point *currPt, Point *prevPt, Point *startPt) {}
  72.    virtual voidEndTracking(Point *currPt, Point *prevPt, Point *startPt) {}
  73. };
  74.  
  75.  
  76.  
  77.  
  78.  
  79. extern class CBureaucrat   *gGopher;   /* First in line to get commands*/
  80.  
  81. class CBureaucrat {/* Class Declaration*/
  82.  
  83. protected:
  84.    /** Instance Variables **/
  85.    CBureaucrat *itsSupervisor; /* Its boss in the command chain*/
  86.  
  87.    CBureaucrat(CBureaucrat *aSupervisor) { itsSupervisor = aSupervisor; }
  88.    virtual ~CBureaucrat(void) { if (gGopher == this)  gGopher = itsSupervisor;
  89.  
  90. public:
  91.    /** Accessing **/
  92.    CBureaucrat *GetSupervisor(void) { return(itsSupervisor); }
  93.  
  94.    /** Commanding **/
  95.    virtual voidNotify(CTask *theTask) { itsSupervisor->Notify(theTask); }
  96.    virtual voidDoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent) {
  97.    itsSupervisor->DoKeyDown(theChar, keyCode, macEvent);
  98.    }
  99.    virtual voidDoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent) {
  100.    itsSupervisor->DoAutoKey(theChar, keyCode, macEvent);
  101.    }
  102.    virtual voidDoKeyUp(char theChar, Byte keyCode, EventRecord *macEvent) {
  103.    itsSupervisor->DoKeyUp(theChar, keyCode, macEvent);
  104.    }
  105.    virtual voidDoCommand(long theCommand) {
  106. itsSupervisor->DoCommand(theCommand); }
  107.    virtual voidDawdle(long *maxSleep) {}
  108.    virtual voidUpdateMenus(void) {
  109.    if (itsSupervisor)  itsSupervisor->UpdateMenus();
  110.    }
  111. };
  112.  
  113.  
  114.  
  115. class CCollection {/* Class Declaration*/
  116.  
  117. protected:
  118.  
  119.    longnumItems;   /* Number of items in collection*/
  120.  
  121.    CCollection(void) { numItems = 0L; };
  122.  
  123. public:
  124.    /** Instance Methods **/
  125.    longGetNumItems(void) { return(numItems); };/* Retrieve size of collection
  126. */
  127.    Boolean IsEmpty(void) { return(numItems == 0L); };  /* Is the collection
  128. empty? */
  129. };
  130.  
  131.  
  132.  
  133.  
  134.  
  135. #defineSLOT_SIZE   4   /* Byte size of a slot. A slot  */  /*   holds
  136. a handle to an object. */
  137. #defineBAD_INDEX   -1L /* Flag indicating a failed search  */
  138.  
  139. class CCluster : public CCollection {  /* Class Declaration*/
  140.  
  141. protected:
  142.  
  143.    short   blockSize;  /* Number of slots to allocate when */
  144.    /*  more space is needed*/
  145.    short   slots;  /* Total number of slots allocated  */
  146.    LongHandle  items;  /* Items in the cluster */
  147.  
  148. public:
  149.  
  150.    CCluster(void); /* Initialization   */
  151.    virtual ~CCluster(void) { DisposHandle((Handle)items); }/* Dispose of a
  152. Cluster*/
  153.  
  154.    virtual voidDisposeAll(void);   /* Dispose of Cluster and all items */
  155.    virtual voidDisposeItems(void); /* Dispose of all items in Cluster  */
  156.  
  157.    /* Specify a new blockSize  */
  158.    virtual voidSetBlockSize(short aBlockSize) { blockSize = aBlockSize; }
  159.    /* Add an object to the cluster */
  160.    virtual voidAdd(long *theObject);
  161.    /* Remove an object */
  162.    virtual voidRemove(long *theObject);
  163.    /* Test for inclusion of an object  */
  164.    virtual Boolean Includes(long *theObject) { return(Offset(theObject) !=
  165. BAD_INDEX); }
  166.    virtual voidDoForEach(VoidFunc theFunc) {
  167.    register long   i;
  168.  
  169.    for (i = 0; i < numItems; i++)  // Call a function for each item
  170.    (*theFunc)((*items)[i]);
  171.    }
  172.    virtual voidDoForEach1(VoidFunc theFunc, long param){
  173.    register long   i;
  174.  
  175.    for (i = 0; i < numItems; i++)  // Call a function for each item
  176.    (*theFunc)((*items)[i],param);
  177.    }
  178.    virtual voidMoreSlots(void) {   /* Allocate additional slots*/
  179.    slots += blockSize;
  180.    SetHandleSize((Handle)items, (long)(slots * SLOT_SIZE));
  181.    }
  182.    virtual long*   FindItem(BooleanFunc);
  183.    virtual long*   FindItem1(BooleanFunc, long param);
  184.    /* Find offset of object in cluster */
  185.    virtual longOffset(long *theObject);
  186. };
  187.  
  188.  
  189.  
  190.  
  191. class CList : public CCluster {/* Class Declaration*/
  192.  
  193. public:
  194.    /** Instance Methods **/
  195.    virtual voidRemove(long *theObject);
  196.    virtual voidAppend(long *theObject) { CCluster::Add(theObject); }
  197.    virtual voidPrepend(long *theObject);
  198.    virtual voidInsertAfter(long *theObject, long *afterObject);
  199.    virtual voidInsertAt(long *theObject, long index);
  200.  
  201.    virtual voidBringFront(long *theObject);
  202.    virtual voidSendBack(long *theObject);
  203.    virtual voidMoveUp(long *theObject);
  204.    virtual voidMoveDown(long *theObject);
  205.    virtual voidMoveToIndex(long *theObject, long index);
  206.  
  207.    virtual long*   FirstItem(void) { return(NthItem(1)); }
  208.    virtual long*   LastItem(void) { return(NthItem(numItems)); }
  209.    virtual long*   NthItem(long n);
  210.    virtual longFindIndex(long *theObject) { return(Offset(theObject) + 1); }
  211.    virtual long*   FirstSuccess(BooleanFunc testFunc) {
  212. return(CCluster::FindItem(testFunc)); }
  213.    virtual long*   FirstSuccess1(BooleanFunc testFunc, long param) {
  214. return(CCluster::FindItem1(testFunc, param)); }
  215.    virtual long*   LastSuccess(BooleanFunc testFunc);
  216.    virtual long*   LastSuccess1(BooleanFunc testFunc, long param);
  217. };
  218.  
  219.  
  220.  
  221.  
  222.  
  223. class CView : public CBureaucrat { /* Class Declaration*/
  224.  
  225. protected:
  226.  
  227.    CView(CView *anEnclosure, CBureaucrat *aSupervisor);
  228.    CView(ResType rType, short resID, CView *anEnclosure, CBureaucrat
  229. *aSupervisor);
  230.    ~CView(void);
  231.    virtual voidAdjustScrollMax(void) {}// MPW has no 'member' function (see
  232. Scrollbar)
  233.  
  234. public:
  235.    /** Instance Variables **/
  236.    GrafPtr macPort;/* Mac drawing port for the image   */
  237.    CView   *itsEnclosure;  /* Enclosing view   */
  238.    CList   *itsSubviews;   /* Views within this view   */
  239.    Boolean visible;/* Is the view visible? */
  240.    Boolean active; /* Is the view active?  */
  241.    Boolean wantsClicks;/* Does view handle mouse clicks?   */
  242.  
  243.    /** Instance Methods **/
  244.    /** Construction/Destruction **/
  245.  
  246.    virtual voidIViewTemp(Ptr *viewData);
  247.  
  248.    /** Accessing **/
  249.    virtual Boolean IsVisible(void) { return(visible); }
  250.    virtual Boolean IsActive(void);
  251.    virtual Boolean ReallyVisible(void) {
  252.    if (visible)
  253.    return(itsEnclosure->ReallyVisible());
  254.    else
  255.    return(false);
  256.    }
  257.    virtual GrafPtr GetMacPort(void) {  return(macPort); };
  258.    virtual voidGetOrigin(long *theHOrigin, long *theVOrigin) { *theHOrigin =
  259. *theVOrigin = 0L; }
  260.    virtual voidGetFrame(Rect *theFrame) {}
  261.    virtual voidGetInterior(Rect *theInterior) { GetFrame(theInterior); }
  262.    virtual voidGetAperture(Rect *theAperture) {}
  263.    virtual Boolean Contains(Point thePoint) {}
  264.    virtual voidSetWantsClicks(Boolean aWantsClicks) { wantsClicks =
  265. aWantsClicks; }
  266.  
  267.    /** Appearance **/
  268.    virtual voidShow(void) { visible = true; }
  269.    virtual voidHide(void) {
  270.    visible = false; if (gGopher == this) gGopher = itsSupervisor;
  271.    }
  272.    virtual voidActivate(void);
  273.    virtual voidDeactivate(void);
  274.  
  275.    /** Mouse **/
  276.    virtual voidDispatchClick(EventRecord *macEvent);
  277.    virtual voidDoClick(Point hitPt, short modifierKeys, long when) {}
  278.    virtual Boolean HitSamePart(Point pointA, Point pointB) { return(true); }
  279.    virtual voidDoMouseUp(EventRecord *macEvent) {}
  280.    virtual voidTrackMouse(CMouseTask *theTask, Point startPt, Rect *pinRect);
  281.  
  282.    /** Cursor **/
  283.    voidDispatchCursor(Point where, RgnHandle mouseRgn);
  284.    voidAdjustCursor(Point where, RgnHandle mouseRgn) { SetCursor(&(qd.arrow));
  285. }
  286.  
  287.    /** Subview Management **/
  288.    voidAddSubview(CView *theSubview);
  289.    voidRemoveSubview(CView *theSubview) {
  290. itsSubviews->Remove((long*)theSubview); }
  291.    CView*  FindSubview(Point hitPt);
  292.    voidSubpaneLocation(short hEncl, short vEncl,
  293.    long *hLocation, long *vLocation);
  294.    virtual voidPrepare(void) {}
  295.    virtual voidFrameToGlobalR(Rect *theRect) {}
  296. };
  297.  
  298.  
  299. typedef struct {   /* View template*/
  300.    short   visible;
  301.    short   active;
  302.    short   wantsClicks;
  303. } ViewTemp, *ViewTempP;
  304.  
  305.  
  306. void   CountClicks(CView *hitView, EventRecord *macEvent);
  307.  
  308.  
  309.  
  310.  
  311.  
  312. class CEnvironment {   /* Class Declaration*/
  313.  
  314. public:
  315.    /** Instance Methods **/
  316.    virtual voidRestore(void) { PenNormal(); };
  317. };
  318.  
  319.  
  320.  
  321.  
  322.  
  323.    /** How pane changes size when the size of its enclosure changes **/
  324.  
  325. typedef enum SizingOption  {
  326.    sizFIXEDLEFT,   /* Fixed length, anchored to left   */
  327.    sizFIXEDRIGHT,  /* Fixed length, anchored to right  */
  328.    sizFIXEDTOP,/* Fixed length, anchored to top    */
  329.    sizFIXEDBOTTOM, /* Fixed length, anchored to bottom */
  330.    sizFIXEDSTICKY, /* Fixed length, sticks to coords   */
  331.    /*   of its enclosure   */
  332.    sizELASTIC  /* Variable length, always a fixed  */
  333.    /*   amount smaller than enclosure  */
  334. } SizingOption;
  335.  
  336. typedef enum ClipOption{
  337.    clipAPERTURE,
  338.    clipFRAME,
  339.    clipPAGE
  340. } ClipOption;
  341.  
  342.  
  343. class CPane : public CView {   /* Class Declaration*/
  344.  
  345. friend void Pane_AdjustToEnclosure(CPane *thePane, Rect *delta);
  346. friend void Pane_CalcAperture(CPane *thePane);
  347. friend void Pane_Draw( CPane *thePane, Rect *area);
  348. friend void Pane_EnclosureScrolled(CPane *thePane, Point *offset);
  349.  
  350. protected:
  351.  
  352.    short   width;  /* Horizontal size in pixels*/
  353.    short   height; /* Vertical size in pixels  */
  354.    short   hEncl;  /* Horizontal location in enclosure */
  355.    short   vEncl;  /* Vertical location in enclosure   */
  356.    SizingOptionhSizing;/* Horizontal sizing option */
  357.    SizingOptionvSizing;/* Vertical sizing option   */
  358.    Boolean autoRefresh;/* Refresh all after a resize?  */
  359.    Rectframe;  /* Area for displaying the Pane */
  360.    /*   which defines Frame coords */
  361.    Rectaperture;   /* Active drawing area of the Pane  */
  362.    longhOrigin;/* Window left in Frame coords  */
  363.    longvOrigin;/* Window top in Frame coords   */
  364.    CEnvironment*itsEnvironment;/* Drawing environment  */
  365.    ClipOption  printClip;  /* Clipping option when printing*/
  366.    Boolean printing;   /* Is printing in progress? */
  367.  
  368.    voidGetOrigin(long *theHOrigin, long *theVOrigin) {
  369.    *theHOrigin = hOrigin; *theVOrigin = vOrigin;
  370.    };
  371.    voidAdjustToEnclosure(Rect *deltaEncl);
  372.    voidAdjustHoriz(Rect *deltaEncl, Rect *delta, short *offset,
  373.    Boolean *moved, Boolean *sized);
  374.    voidAdjustVert(Rect *deltaEncl, Rect *delta, short *offset,
  375.    Boolean *moved, Boolean *sized);
  376.    voidEnclosureScrolled(short hOffset, short vOffset);
  377.    voidCalcAperture(void);
  378.  
  379. public:
  380.    /** Construct/Destruction **/
  381.    CPane(CView *anEnclosure, CBureaucrat *aSupervisor,
  382.    short aWidth, short aHeight, short aHEncl, short aVEncl,
  383.    SizingOption aHSizing, SizingOption aVSizing);
  384.    CPane(ResType rType, short resID, CView *anEnclosure, CBureaucrat
  385. *aSupervisor)
  386.    : CView(rType, resID, anEnclosure, aSupervisor) {}
  387.    ~CPane(void);
  388.  
  389.    virtual voidIViewTemp(Ptr *viewData);
  390.    virtual voidIPaneX(void);
  391.  
  392.    /** Accessing **/
  393.    virtual voidSetFrameOrigin(short fLeft, short fTop);
  394.    virtual voidGetFrame(Rect *theFrame) { *theFrame = frame; };
  395.    virtual voidGetLengths(short *theWidth, short *theHeight);
  396.    virtual voidGetAperture(Rect *theAperture) { *theAperture = aperture; };
  397.    virtual Boolean Contains(Point thePoint) {
  398.    WindToFrame(&thePoint); /* Convert to Frame coordinates */
  399.    return(PtInRect(thePoint, &aperture));  /* Is point inside aperture?*/
  400.    };
  401.    virtual Boolean ReallyVisible(void);
  402.    virtual voidGetPixelExtent(long *hExtent, long *vExtent);
  403.    virtual voidSetPrintClip(ClipOption aPrintClip) { printClip = aPrintClip; };
  404.  
  405.    /** Display **/
  406.    virtual voidShow(void) {
  407.    if (!visible) {
  408.    CView::Show();
  409.    Refresh();
  410.    }
  411.    };
  412.    virtual voidHide(void) {
  413.    if (visible) {
  414.    Refresh();
  415.    CView::Hide();
  416.    }
  417.    };
  418.  
  419.    /** Size and Location **/
  420.    virtual voidPlace(short hEncl, short vEncl, Boolean redraw);
  421.    virtual voidOffset(short hOffset, short vOffset, Boolean redraw);
  422.    virtual voidChangeSize(Rect *delta, Boolean redraw);
  423.  
  424.    /** Adapting **/
  425.    virtual voidFitToEnclosure(Boolean horizFit, Boolean vertFit);
  426.    virtual voidFitToEnclFrame(Boolean horizFit, Boolean vertFit);
  427.    virtual voidCenterWithinEnclosure(Boolean horizCenter, Boolean vertCenter);
  428.  
  429.    /** Drawing **/
  430.    virtual voidDraw(Rect *area) {};
  431.    virtual voidDrawAll(Rect *area);
  432.    virtual voidRefresh(void);
  433.    virtual voidRefreshRect(Rect *area);
  434.  
  435.    /** Printing **/
  436.  
  437.    virtual voidAboutToPrint(short *firstPage, short *lastPage) { printing =
  438. true; };
  439.    virtual voidPrintPage(short pageNum, short pageWidth, short pageHeight);
  440.    virtual voidDonePrinting(void) { printing = false; };
  441.    virtual voidPrepareToPrint(void);
  442.  
  443.    /** Calibrating **/
  444.    virtual voidPrepare(void);
  445.    virtual voidRestoreEnvironment(void) { if (itsEnvironment)
  446. itsEnvironment->Restore(); };
  447.    virtual voidCalcFrame(void);
  448.    virtual voidResizeFrame(Rect *delta);
  449.  
  450.    /** Coordinate Transforms **/
  451.    virtual voidWindToFrame(Point *thePoint) {
  452.    thePoint->h += (short) hOrigin;
  453.    thePoint->v += (short) vOrigin;
  454.    };
  455.    virtual voidWindToFrameR(Rect *theRect) { OffsetRect(theRect, (short)
  456. hOrigin, (short) vOrigin); };
  457.    virtual voidFrameToWind(Point *thePoint) {
  458.    thePoint->h -= (short) hOrigin;
  459.    thePoint->v -= (short) vOrigin;
  460.    };
  461.    virtual voidFrameToWindR(Rect *theRect) {
  462.    OffsetRect(theRect, -(short) hOrigin, -(short) vOrigin);
  463.    };
  464.    virtual voidEnclToFrame(Point *thePoint) {
  465.    longenclHOrigin;
  466.    longenclVOrigin;
  467.  
  468.    itsEnclosure->GetOrigin(&enclHOrigin, &enclVOrigin);
  469.    thePoint->h += (short) (hOrigin - enclHOrigin);
  470.    thePoint->v += (short) (vOrigin - enclVOrigin);
  471.    };
  472.    virtual voidEnclToFrameR(Rect *theRect) {
  473.    longenclHOrigin;
  474.    longenclVOrigin;
  475.  
  476.    itsEnclosure->GetOrigin(&enclHOrigin, &enclVOrigin);
  477.    OffsetRect(theRect, (short) (hOrigin - enclHOrigin),
  478.    (short) (vOrigin - enclVOrigin));
  479.    };
  480.    virtual voidFrameToEncl(Point *thePoint) {
  481.    longenclHOrigin;
  482.    longenclVOrigin;
  483.  
  484.    itsEnclosure->GetOrigin(&enclHOrigin, &enclVOrigin);
  485.    thePoint->h += (short)(enclHOrigin - hOrigin);
  486.    thePoint->v += (short)(enclVOrigin - vOrigin);
  487.    };
  488.    virtual voidFrameToEnclR(Rect *theRect) {
  489.    longenclHOrigin;
  490.    longenclVOrigin;
  491.  
  492.    itsEnclosure->GetOrigin(&enclHOrigin, &enclVOrigin);
  493.    OffsetRect(theRect, (short)(enclHOrigin - hOrigin),(short)(enclVOrigin -
  494. vOrigin));
  495.    };
  496.    virtual voidFrameToGlobalR(Rect *theRect) {
  497.    Point   offset;
  498.  
  499.    offset = topLeft((**((WindowPeek)macPort)->contRgn).rgnBBox);
  500.    OffsetRect(theRect, offset.h - (short)hOrigin, offset.v -
  501. (short)vOrigin);
  502.    };
  503. };
  504.  
  505.  
  506. typedef struct {   /* Pane template*/
  507.    short   width;
  508.    short   height;
  509.    short   hEncl;
  510.    short   vEncl;
  511.    short   hSizing;
  512.    short   vSizing;
  513.    short   autoRefresh;
  514.    short   printClip;
  515. } PaneTemp, *PaneTempP;
  516.  
  517.    /* Functions passed as arguments to list methods */
  518.  
  519.    voidPane_Draw(CPane *thePane, Rect *area);
  520.    voidPane_AdjustToEnclosure(CPane *thePane, Rect *delta);
  521.  
  522.  
  523.  
  524.  
  525.  
  526. class CPanorama : public CPane {   /* Class Declaration*/
  527.  
  528. protected:
  529.  
  530.    Rectbounds; /* Bounds defining Pane coordinates */
  531.    short   hScale; /* Pixels per horizontal unit   */
  532.    short   vScale; /* Pixels per vertical unit */
  533.    Point   position;   /* Location of frame in Panorama*/
  534.    Point   savePosition;   /* Save for later restoration   */
  535.    class CScrollPane   *itsScrollPane; /* Scroll pane for this Panorama*/
  536.  
  537.    voidGetFramePosition(long *theHPos, long *theVPos) {
  538.    *theHPos = position.h - bounds.left;
  539.    *theVPos = position.v - bounds.top;
  540.    };
  541.  
  542. friend class CScrollPane;
  543.  
  544. public:
  545.    /** Contruction/Destruction **/
  546.    CPanorama(CView *anEnclosure, CBureaucrat *aSupervisor,
  547.    short aWidth, short aHeight,
  548.    short aHEncl, short aVEncl,
  549.    SizingOption aHSizing, SizingOption aVSizing);
  550.    CPanorama(ResType rType, short resID, CView *anEnclosure, CBureaucrat
  551. *aSupervisor)
  552.    : CPane(rType, resID, anEnclosure, aSupervisor) {}
  553.  
  554.    voidIViewTemp(Ptr *viewData);
  555.  
  556.    /** Accessing **/
  557.    virtual voidGetExtent(long *theHExtent, long *theVExtent) {
  558.    *theHExtent = bounds.right - bounds.left;
  559.    *theVExtent = bounds.bottom - bounds.top;
  560.    };
  561.    virtual voidGetFrameSpan(short *theHSpan, short *theVSpan) {
  562.    *theHSpan = width / hScale; /*   We get the number of complete  */
  563.    *theVSpan = height / vScale;/*   units spanned by the frame */
  564.    };
  565.    virtual voidSetBounds(Rect *aBounds);
  566.    virtual voidGetBounds(Rect *theBounds) { *theBounds = bounds; };
  567.    virtual voidSetPosition(Point aPosition);
  568.    virtual voidGetPosition(Point *thePosition) { *thePosition = position; };
  569.    virtual voidSetScales(short aHScale, short aVScale);
  570.    virtual voidGetScales(short *theHScale, short *theVScale) {
  571.    *theHScale = hScale;/* Return copies of instance vars   */
  572.    *theVScale = vScale;
  573.    };
  574.    virtual voidSetScrollPane(struct CScrollPane *aScrollPane) { itsScrollPane =
  575. aScrollPane; };
  576.  
  577.    virtual voidGetHomePosition(Point *theHomePos) { *theHomePos =
  578. topLeft(bounds); };
  579.    virtual voidGetPixelExtent(long *hExtent, long *vExtent) {
  580.    *hExtent = (bounds.right - bounds.left) * hScale;
  581.    *vExtent = (bounds.bottom - bounds.top) * vScale;
  582.    };
  583.  
  584.    /** Calibrating **/
  585.    virtual voidResizeFrame(Rect *delta);
  586.  
  587.    /** Scrolling **/
  588.    virtual voidScroll(short hDelta, short vDelta, Boolean redraw);
  589.    virtual voidScrollTo(Point aPosition, Boolean redraw);
  590.    virtual voidScrollToSelection(void) {};
  591.    virtual Boolean AutoScroll(Point mouseLoc);
  592.  
  593.    /** Printing **/
  594.    virtual voidAboutToPrint(short *firstPage, short *lastPage);
  595.    virtual voidPrintPage(short pageNum, short pageWidth, short pageHeight);
  596.    virtual voidDonePrinting(void);
  597. };
  598.  
  599.  
  600. typedef struct {   /* Panorama template*/
  601.    Rectbounds;
  602.    short   hScale;
  603.    short   vScale;
  604.    Point   position;
  605. } PanoramaTemp, *PanoramaTempP;
  606.  
  607.  
  608.  
  609.  
  610.  
  611. typedef enum {
  612.    hiliteOFF,
  613.    hiliteON,
  614.    hiliteDYNAMIC
  615. } HiliteState;
  616.  
  617. class CSelector : public CPanorama {   /* Class Declaration*/
  618.  
  619. protected:
  620.    /** Instance Variables **/
  621.    short   numItems;   /* Number of items to choose from   */
  622.    short   selection;  /* Currently selected item  */
  623.    short   commandBase;/* Base value of selection command  */
  624.  
  625. public:
  626.    /** Instance Methods **/
  627.    CSelector(CView *anEnclosure, CBureaucrat *aSupervisor,
  628.    short aWidth, short aHeight,
  629.    short aHEncl, short aVEncl,
  630.    SizingOption aHSizing, SizingOption aVSizing,
  631.    short aNumItems, short aSelection,
  632.    short aCommandBase);
  633.  
  634.    CSelector(ResType rType, short resID, CView *anEnclosure, CBureaucrat
  635. *aSupervisor)
  636.    : CPanorama(rType,resID,anEnclosure,aSupervisor) {}
  637.  
  638.    voidIViewTemp(Ptr *viewData);
  639.  
  640.    voidDoClick(Point hitPt, short modifierKeys, long when);
  641.    Boolean HitSamePart(Point pointA, Point pointB);
  642.  
  643.    virtual voidChangeSelection(short aSelection);
  644.    virtual short   GetSelection(void) { return(selection); }
  645.    virtual voidSetCommandBase(short aCommandBase) { commandBase = aCommandBase;
  646. }
  647.    virtual short   GetCommandBase(void) { return(commandBase); }
  648.    virtual voidHiliteItem(short theItem, HiliteState state) {}
  649.    virtual short   FindItem(Point hitPt) { return(NOTHING); }
  650.    virtual voidDoDoubleClick(void) {}
  651. };
  652.  
  653. typedef struct {   /* Resource template for a  */
  654.    short   numItems;   /*   Selector View  */
  655.    short   selection;
  656.    short   commandBase;
  657. } SelectorTemp, *SelectorTempP;
  658.  
  659.  
  660.  
  661.  
  662. class CGridSelector : public CSelector {   /* Class Declaration*/
  663.  
  664. protected:
  665.    /** Instance Variables **/
  666.    short   rows;
  667.    short   columns;
  668.    short   boxWidth;
  669.    short   boxHeight;
  670.    Boolean gridOn;
  671.  
  672. public:
  673.    /** Instance Methods **/
  674.    CGridSelector(CView *anEnclosure, CBureaucrat *aSupervisor,
  675.    short aHEncl, short aVEncl,
  676.    SizingOption aHSizing, SizingOption aVSizing,
  677.    short aSelection, short aCommandBase,
  678.    short aRows, short aColumns,
  679.    short aBoxWidth, short aBoxHeight);
  680.    CGridSelector(ResType rType, short resID, CView *anEnclosure, CBureaucrat
  681. *aSupervisor)
  682.    : CSelector(rType,resID,anEnclosure,aSupervisor) {}
  683.  
  684.    voidIViewTemp(Ptr *viewData);
  685.  
  686.    voidDraw(Rect *area);
  687.    voidHiliteItem(short theItem, HiliteState state);
  688.    short   FindItem(Point hitPt);
  689.  
  690.    virtual voidDrawGrid(void);
  691.    virtual voidDrawItem(short theItem, Rect *theBox) {}
  692.    virtual voidFindItemBox(short theItem, Rect *theBox);
  693.    virtual voidSetGridOn(Boolean aGridOn) { gridOn = aGridOn; }
  694. };
  695.  
  696. typedef struct {   /* Resource template for a  */
  697.    short   rows;   /*   character grid */
  698.    short   columns;
  699.    short   BoxWidth;
  700.    short   BoxHeight;
  701. } GridSelectorTemp, *GridSelectorTempP;
  702.  
  703.  
  704.  
  705.  
  706. class CCharGrid : public CGridSelector {   /* Class Declaration*/
  707.  
  708. protected:
  709.  
  710.    Handle  theCharacters;  /* Characters within the grid   */
  711.  
  712. public:
  713.    /** Instance Methods **/
  714.    ~CCharGrid(void) { DisposHandle(theCharacters); }
  715.  
  716.    CCharGrid(  CView *anEnclosure, CBureaucrat *aSupervisor,
  717.    short rows, short cols,
  718.    short boxWidth, short boxHeight,
  719.    SizingOption hSizing, SizingOption vSizing,
  720.    short hLoc, short vLoc,
  721.    short commandBase,
  722.    short theSize,
  723.    char *extra);
  724.    CCharGrid(short ChGdid, CView *anEnclosure, CBureaucrat *aSupervisor)
  725.    : CGridSelector('ChGd',ChGdid,anEnclosure,aSupervisor) {}
  726.  
  727.    voidIViewTemp(Ptr *viewData);
  728.  
  729.    voidDrawItem(short theItem, Rect *theBox);
  730. };
  731.  
  732. typedef struct {   /* Resource template for a  */
  733.    short   rows;   /*   character grid */
  734.    short   cols;
  735.    short   boxWidth;
  736.    short   boxHeight;
  737.    short   hSizing;
  738.    short   vSizing;
  739.    short   hLoc;
  740.    short   vLoc;
  741.    short   commandBase;
  742.    short   theSize;
  743.    char*extra;
  744. } CharGridTemp, *CharGridTempP;
  745.  
  746.  
  747.  
  748.  
  749. /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  750. /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  751. /*!!!!!!!!!!!!!!!!!!!!!!!!!!!    THE PROBLEM      !!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  752. /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  753. /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  754.  
  755. void   CCharGrid::IViewTemp(Ptr *viewData)
  756. {
  757. }
  758.  
  759.  
  760.  
  761.  
  762. End of CFront execution
  763.  
  764. Apple 'C' compiler V3.1 (10/6/89 5:24:39 PM)
  765. (c) 1987-1989 Apple Computer, Inc.
  766.  
  767. Compiling : ":C.pipe.code.c"
  768.  __ct__13CGridSelectorFUlsP5CViewP11CBureaucrat
  769.  Restore__12CEnvironmentFv
  770.  UpdateMenus__11CBureaucratFv
  771.  Dawdle__11CBureaucratFPl
  772.  DoCommand__11CBureaucratFl
  773.  DoKeyUp__11CBureaucratFcUcP11EventRecord
  774.  DoAutoKey__11CBureaucratFcUcP11EventRecord
  775.  DoKeyDown__11CBureaucratFcUcP11EventRecord
  776.  Notify__11CBureaucratFP5CTask
  777.  __dt__11CBureaucratFv
  778.  EndTracking__10CMouseTaskFP5PointN21
  779.  KeepTracking__10CMouseTaskFP5PointN21
  780.  BeginTracking__10CMouseTaskFP5Point
  781.  Redo__5CTaskFv
  782.  Undo__5CTaskFv
  783.  Do__5CTaskFv
  784. # Starting code generation...
  785.   274 __ct__13CGridSelectorFUlsP5CViewP11CBureaucrat
  786.    38 Restore__12CEnvironmentFv
  787.    84 UpdateMenus__11CBureaucratFv
  788.    36 Dawdle__11CBureaucratFPl
  789.    80 DoCommand__11CBureaucratFl
  790.   118 DoKeyUp__11CBureaucratFcUcP11EventRecord
  791.   120 DoAutoKey__11CBureaucratFcUcP11EventRecord
  792.   120 DoKeyDown__11CBureaucratFcUcP11EventRecord
  793.    88 Notify__11CBureaucratFP5CTask
  794.    84 __dt__11CBureaucratFv
  795.    48 EndTracking__10CMouseTaskFP5PointN21
  796.    50 KeepTracking__10CMouseTaskFP5PointN21
  797.    48 BeginTracking__10CMouseTaskFP5Point
  798.    50 Redo__5CTaskFv
  799.    26 Undo__5CTaskFv
  800.    24 Do__5CTaskFv
  801. # Total code size = 1288
  802.  
  803.  
  804.  
  805. Frank Stock
  806. DSBB:Developers Ask Each Other:General Discussion
  807. 3/21/90
  808.  
  809.